# Contributor: Raed Rizqie <raed.rizqie@gmail.com>

_realname=lsp-black
pkgbase=mingw-w64-python-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-python-${_realname}
pkgver=1.2.1
pkgrel=2
pkgdesc='Black plugin for the Python LSP Server (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
license=('MIT')
url='https://github.com/python-lsp/python-lsp-black'
depends=(
    ${MINGW_PACKAGE_PREFIX}-python
    ${MINGW_PACKAGE_PREFIX}-python-black
    ${MINGW_PACKAGE_PREFIX}-python-lsp-server
    ${MINGW_PACKAGE_PREFIX}-python-toml)
makedepends=(
    ${MINGW_PACKAGE_PREFIX}-python-setuptools)
source=(https://github.com/python-lsp/python-${_realname}/archive/v${pkgver}.tar.gz)
sha256sums=('1df12c5d3f6407040dd0020a918ed98b20c1ba68720e662f7c8044ed15f87186')

prepare() {
  cd "${srcdir}"
  rm -rf python-build-${MSYSTEM} | true
  cp -r "python-${_realname}-${pkgver}" "python-build-${MSYSTEM}"
}

build() {
  msg "Python build for ${MSYSTEM}"
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
